﻿Public Class clsCPCKIN
    Public Function getWarehouseInByStatus(status As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT a.*,b.mes_project_name,b.mes_project_code,c.prod_spec_name FROM sf.b_warehouse_in a "
        szSql &= " left join sf.b_pgd_mes b on a.pgd_id::integer = b.sys_id "
        szSql &= " left join sf.t_prod_spec c on a.prod_spec_id = c.prod_spec_id "
        szSql &= "WHERE a.mes_sync_status = ? "
        Return DBacs.ExecuteSql(szSql, -1, status)
    End Function

    Public Function getWarehouseInList(startTime As String, endTime As String) As DataTable
        Dim szSql As String = ""
        szSql &= "SELECT a.*,b.mes_project_name,b.mes_project_code,c.prod_spec_name FROM sf.b_warehouse_in a "
        szSql &= " left join sf.b_pgd_mes b on a.pgd_id::integer = b.sys_id "
        szSql &= " left join sf.t_prod_spec c on a.prod_spec_id = c.prod_spec_id "
        szSql &= " where 1=1 "
        If startTime <> "" Then
            szSql &= " and a.update_time >= '" + startTime + "'"
        End If
        If endTime <> "" Then
            szSql &= " and a.update_time <= '" + endTime + "'"
        End If
        Return DBacs.ExecuteSql(szSql, -1)
    End Function

    Public Function update(mes_sync_status As String, mes_sync_msg As String, mes_sync_ope As String, sys_id As String) As Integer
        Dim sql As String = "update sf.b_warehouse_in set mes_sync_status = ?, mes_sync_msg = ?, mes_sync_ope = ?, update_time=(SELECT CURRENT_TIMESTAMP(6)) where sys_id = ? "
        Return DBacs.ExecuteUpdateSql(sql, -1, mes_sync_status, mes_sync_msg, mes_sync_ope, sys_id)
    End Function

End Class
